﻿@using LotteryVoteMVC.Models
@using LotteryVoteMVC.Resources
@using LotteryVoteMVC.Utility
@model PagedList<Bulletin>
@{
    ViewBag.Title = Resource.Message;
    Layout = "~/Views/Shared/Main.cshtml";
}
@section Header
{
    <link href="@Url.Content("~/Content/TableBase.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/Customer/multipleSubmit.js")" type="text/javascript"></script>
}
@{int index = 1;
  Role role = ViewBag.User == null ? Role.Guest : ViewBag.User.Role;}
<div id="searchBar">
    @using (Html.BeginForm())
    {
        <span>@Resource.Content</span>
        <input type="text" id="Content" name="Content" style="width: 300px" />
        <input type="submit" id="search" name="search" value="@Resource.Search" />
        if (role == Role.Company)
        {
        <input type="submit" id="add" name="add" value="@Resource.Add" action="/Message/Add"/>
        }
    }
</div>
<table>
    <thead>
        <tr>
            <td>@Resource.No
            </td>
            <td>@Resource.Time
            </td>
            <td>@Resource.Content
            </td>
            @if (role == Role.Company)
            { 
                <td>@Resource.Delete
                </td>
            }
        </tr>
    </thead>
    <tbody>
        @foreach (var bulletin in Model)
        {
            <tr>
                <td>@(index++)
                </td>
                <td>@bulletin.CreateTime
                </td>
                <td>@bulletin.Content
                </td>
                @if (role == Role.Company)
                {
                    <td>
                        @Html.ActionLink(Resource.Delete, "Remove", new { Id = bulletin.BulletinId })
                    </td>
                }
            </tr>
        }
    </tbody>
</table>
